package top.oylan.mp.controller.admin;

import org.apache.shiro.SecurityUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.oylan.mp.entity.Menu;
import top.oylan.mp.entity.User;
import top.oylan.mp.service.UserService;
import top.oylan.mp.utils.Result;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminIndexController {

    @Resource
    UserService userService;

    @RequestMapping("/menus")
    public Result menus() {
        Result result = new Result();
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        List<Menu> menus = userService.selectPromisedMenus(user.getId());
        result.setData(menus);
        return result;
    }
}
